home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_077 / language.doc / crt.ref next >
Text File  |  1992-05-06  |  17KB  |  379 lines

  1. ******
  2. NOTE: this description refers to the CP/M-80 version of the CRT library. I
  3. haven't had time to update it. Most calls are the same in the Amiga version,
  4. but a couple differ (e.g. CRT_Initialize) and some new ones were added to
  5. support scrolling regions on the console. Refer to include:crt.g for
  6. declarations of the routines actually supported in the Amiga version.
  7.  
  8. A special note on CRT_Initialize: if the lines and columns parameters are
  9. both <= 1 then a window as large as possible is created. A value of 0 keeps
  10. the border in that dimension, 1 will use all available space. Thus 1, 1 on
  11. a non-interlaced screen will make a 23 line by 77 character window; 0, 0 on
  12. an interlaced screen will make a 50 line by 80 column window. Use CRT_NLines
  13. and CRT_NCols to find the actual size you got (and thus your program will
  14. run on either non-interlaced or interlaced screens).
  15. ******
  16.  
  17.                The Draco CRT Library
  18.  
  19.             Copyright 1983 by Chris Gray
  20.  
  21.  
  22. The Routines Provided in CRT.LIB
  23.  
  24.     The routines in CRT.LIB are declared in a Draco include file, CRT.G,
  25. which should be included via '\crt.g' at the beginning of each file of your
  26. program. If you use any of the CRT routines, you must include CRT.LIB, the
  27. library which actually contains the routines, as one of the parameters to the
  28. link-editor when you link-edit your program. Additional include file FORM.G
  29. is needed only if you use the form routines in the CRT library. Any program
  30. which correctly uses the CRT routines can (and must) be configured using the
  31. CONFIG.COM program before it can be used. This configuration inserts into
  32. the linked .COM program (renamed as .SET) the control sequences needed for
  33. the terminal the program is to run on. This is inconvenient for the
  34. programmer, but allows the program to be configurable without any additional
  35. effort.
  36.  
  37.     Note that this version of the CRT library only supports systems in which
  38. all actions are done by sending special control sequences out through CP/M's
  39. normal console driver (the DirectConsoleIO system call is used). An earlier
  40. attempt was made to provide a different version which supports memory-
  41. mapped character displays. This version was abandoned due to difficulties
  42. with generalizing things like cursor handling.
  43.  
  44.     The CRT routines require initialization before they will operate
  45. correctly. This is done by one of the magic '_initialize' routines which
  46. will be loaded and called before your 'main' routine is called. Thus, when
  47. using the CRT routines, no special actions need be taken by the programmer,
  48. except that using 'exit' may leave the terminal in a funny state if the
  49. terminal has a termination sequence (which will not be output).
  50.  
  51.     The routines provided in CRT.LIB are:
  52.  
  53.     CRT_NLines()ushort
  54.  
  55.     This call returns the number of lines on the screen of the terminal.
  56.     If your program is to be completely general, it should use the size
  57.     of the terminal to determine the format of the screen.
  58.  
  59.     CRT_NCols()ushort
  60.  
  61.     This call returns the number of columns in each line of the
  62.     terminal's screen. Note that you should avoid putting a character
  63.     in the last column of the last line on the screen, since this can
  64.     cause some terminals to scroll the screen.
  65.  
  66.     CRT_Line()ushort
  67.  
  68.     Returns the line the cursor is currently on.
  69.  
  70.     CRT_Column()ushort
  71.  
  72.     Returns the column the cursor is currently on.
  73.  
  74.     CRT_AbortEnable()void
  75.     CRT_AbortDisable()void
  76.  
  77.     These routines control how the various CRT input routines react when
  78.     a CONTROL-C is typed. The default case is to send the termination
  79.     sequence and return to the operating system. This can be disabled
  80.     by calling 'CRT_AbortDisable', in which case CONTROL-C will be
  81.     either ignored or returned to the caller, depending on which of the
  82.     input routines is in effect. 'CRT_AbortEnable' will re-enable the
  83.     normal abort procedure. It is suggested that aborting not be
  84.     disabled on a program that is under development, since it is often
  85.     handy to be able to abort such programs.
  86.  
  87.     CRT_GetChar()char
  88.  
  89.     This call returns a character typed by the user. The character will
  90.     not appear on the screen, and no processing whatsoever will have
  91.     been done on the character.
  92.  
  93.     CRT_PutChar(char ch)void
  94.  
  95.     The passed character is displayed on the screen at the current
  96.     position. If you have not selected a position yet, then the character
  97.     will appear to the right of the previous character on the screen.
  98.     If the terminal cannot display lower case letters, they will be
  99.     translated into upper case.
  100.  
  101.     CRT_PutChars(*char charsPtr)void
  102.  
  103.     The passed 'chars' value is displayed on the screen.
  104.  
  105.     CRT_ClearScreen()void
  106.  
  107.     The entire screen will be cleared and the cursor will be left in the
  108.     top left-hand corner of the screen.
  109.  
  110.     CRT_ClearLine(ushort line)void
  111.  
  112.     The selected line will be cleared and the cursor will be left at the
  113.     beginning of that line. Note that both lines and columns are numbered
  114.     starting with 0. Thus, the last line on a terminal with 24 lines is
  115.     line number 23.
  116.  
  117.     CRT_ClearTail()void
  118.  
  119.     The current line, from the cursor column to the end of the line, will
  120.     be cleared to spaces. The position of the cursor will be unchanged.
  121.  
  122.     CRT_ClearToEnd(ushort line)void
  123.  
  124.     All lines on the screen from the selected line onward will be
  125.     cleared. The cursor will be left at the beginning of the selected
  126.     line.
  127.  
  128.     CRT_Move(ushort line, col)void
  129.  
  130.     The cursor will be moved to the selected line and column (both are
  131.     0 - origin). Any character output to the screen will appear at that
  132.     position.
  133.  
  134.     CRT_EnterHighLight()void
  135.  
  136.     If the terminal has a reverse video or other accentuation mode, then
  137.     that mode is entered, in that all characters output subsequently
  138.     will appear in that mode.
  139.  
  140.     CRT_ExitHighLight()void
  141.  
  142.     The accentuation of characters (if any) is stopped. All characters
  143.     output subsequently will appear in the normal style.
  144.  
  145.     CRT_Chars(*char charsPtr)void
  146.  
  147.     This routine provides a primitive text-formatting capability within
  148.     the screen of the terminal. The chars value passed can contain
  149.     carriage returns and linefeeds to direct the formatting. The lines
  150.     of text passed will be split up on the spaces between words so that
  151.     each line fits on a screen line. The text will not be right
  152.     justified, however. A sequence of more than one blank will be
  153.     preserved in the output (this is used for paragraph indentation,
  154.     etc.) When all but two lines of the screen have been filled, the
  155.     message 'Press SPACE to continue' will be centered in the bottom
  156.     line, and the routine will wait for the user to enter a space. This
  157.     routine is designed to ease the presentation of on-screen help
  158.     information and user instructions.
  159.  
  160.     CRT_Continue()void
  161.  
  162.     The last line on the screen is cleared, and the message 'Press
  163.     SPACE to continue' will be centered in it. CRT_Continue will not
  164.     return until the user enters a space. This routine can be used to
  165.     give the user time to read or examine some information, before going
  166.     on to another screen of data. The last line is cleared after the
  167.     user enters a space.
  168.  
  169.     CRT_Ask(*chars question)bool
  170.  
  171.     The last line on the screen is cleared, and the passed chars value
  172.     is displayed on that line. The user must then enter a 'y', 'Y', 'n',
  173.     or 'N'. The result from CRT_Ask is 'true' if the user entered a 'y'
  174.     or 'Y', and 'false' if the user entered a 'n' or 'N'. The last line
  175.     is cleared following the user's reply.
  176.  
  177.     CRT_Scroll()void
  178.  
  179.     The screen is scrolled up one line, i.e. the top line is lost, all
  180.     others are moved up one line, and the last is left empty. The cursor
  181.     is left at the beginning of the new empty line.
  182.  
  183.     CRT_Center(ushort line; *char message)void
  184.  
  185.     The given message is displayed centered on the given line.
  186.  
  187.     CRT_Abort()void
  188.  
  189.     The termination sequence is sent to the terminal, and the program is
  190.     terminated.
  191.  
  192.     CRT_Reset()void
  193.  
  194.     The initialization sequence (if any) is sent to the terminal. This,
  195.     in conjunction with a full redraw of the screen, can be done to
  196.     recover from terminal failures, transmission errors, etc.
  197.  
  198.     CRT_Reply1(*char buffer; ushort length; *char prompt)void
  199.  
  200.     The screen is cleared, the prompt is displayed on line 6, and a
  201.     reply from the user (up to the given maximum length) is read into
  202.     the buffer. When entering the reply, the normal editing characters
  203.     (backspace to delete characters, CONTROL-X to delete the entire
  204.     line) are available. The input is terminated with a carriage return.
  205.     The data in the input buffer will always be terminated with a '\e'.
  206.  
  207.     CRT_Reply2(*char buffer; ushort length; *char prompt)void
  208.  
  209.     This is the same as CRT_Reply1, except that the screen is not cleared
  210.     and the question is asked on the last line of the screen.
  211.  
  212.     CRT_GetLine(*char buffer; ushort length)void
  213.  
  214.     An input reply is read, without any additional output being done.
  215.  
  216.     CRT_Read(*char buffer; ushort length; bool skipNext, skipPrev;
  217.          *char terminators, terminator)bool
  218.  
  219.     This is the bottom level input routine used by the above and also
  220.     by the form routines. 'skipNext' enables the termination of input
  221.     when the buffer is full. 'skipPrev' enables a return with an empty
  222.     buffer if the user backspaces past the beginning of the input.
  223.     'terminators' is a string containing the characters other than
  224.     carriage return and linefeed which are allowed to terminate the
  225.     input. 'terminator' returns the termination character that the user
  226.     used. 'true' is returned if the user typed any characters other than
  227.     a terminator. Note that while allowing user input, CONTROL-C aborts
  228.     are only active when the cursor is in the first column of the input.
  229.     This minimizes accidental aborts, but still allows the most common
  230.     use of them.
  231.  
  232.     CRT_Random(word randomRange)word
  233.  
  234.     The CRT routines maintain an internal random number seed, based on
  235.     a counter which spins while waiting for the user to type keys. This
  236.     routine uses that counter as a seed and returns a pseudo-random
  237.     number between 0 and the passed range.
  238.  
  239.     CRT_NonRandom(word seed)void
  240.  
  241.     This routine disables the above-mentioned counter and sets the seed
  242.     to the specified value.
  243.  
  244.     CRT_Error(*char message)void
  245.  
  246.     The given message is displayed on the last line of the screen, and
  247.     an internal flag is set, indicating the presence of an error message.
  248.  
  249.     CRT_ClearError()void
  250.  
  251.     If an error message is present, this routine clears it. A typical
  252.     sequence is to call 'CRT_Error' when something goes wrong, and just
  253.     continue with other processing. Eventually, an input routine will be
  254.     called to get input (often CRT_GetChar in cases where this is most
  255.     useful). After that routine returns with some input, CRT_ClearError
  256.     is called to clear any error. This ensures that the user has had a
  257.     chance to see the error message.
  258.  
  259.     CRT_Menu(*char menu)ushort
  260.  
  261.     This routine displays a menu on the screen, lets the user select an
  262.     entry from it, and returns the 1-origin index of the selected entry.
  263.     User errors are handled using CRT_Error and CRT_ClearError. The
  264.     screen will NOT be cleared on exit, thus giving the user something
  265.     to look at while the computer is off doing whatever it is doing.
  266.     The menu structure passed consists of: zero or more lines of header
  267.     information, separated by carriage returns and/or linefeeds, a '\e',
  268.     one or more menu entries, each terminated by '\e', and a final '\e'.
  269.     CRT_Menu will insert one or two digit indices in front of the menu
  270.     entries, so they should not be given explicitly. An example call:
  271.  
  272.         which := CRT_Menu(
  273.         "This is the first header line\n"
  274.         "\n"
  275.         "This is a second (spaced down) header line\e"
  276.         "menu item number 1\e"
  277.         "menu item number 2\e"
  278.         "menu item number 3\e"
  279.         );
  280.  
  281.     The final '\e' need not be given explicitly, since the compiler
  282.     puts one at the end of all string constants. If the user makes no
  283.     selection, i.e. just hits return, then 0 is returned, else the
  284.     index of the selected entry is returned. The header lines are
  285.     automatically centered within their lines, and the spacing of the
  286.     menu items is governed by their number and the screen size.
  287.  
  288.     The following routines are part of a simple but effective forms entry
  289. system. Using them and the above CRT_Menu routine, fairly fancy "user-
  290. friendly" applications can be written without a lot of the grunge work that
  291. is normally needed. The form routines are included in the CRT library, but
  292. additional include file 'FORM.G' should be included to get declarations of
  293. them and of values they use.
  294.  
  295.     CRT_FormStart()
  296.  
  297.     This routine is called to start the definition of a form. Any
  298.     existing form is thrown away.
  299.  
  300.     CRT_FormInt(ushort line, column, length; *char heading;
  301.         *bool pChanged; *int resultPointer;
  302.         proc (int n)bool checker)void
  303.  
  304.     This adds an integer field to the current input form. The line and
  305.     column are of the header message that will appear to the left of
  306.     the actual input area. 'length' is the number of spaces to be
  307.     allowed for input of the number. The bool pointed to by 'pChanged'
  308.     will be set if the user changes this field. 'resultPointer' points
  309.     at the variable containing both the initial value to be displayed
  310.     in the field, and the final value as modified by the user. The
  311.     'checker' routine is called when the user terminates input for
  312.     this field. It is passed the current value of the input integer. If
  313.     it returns 'true', that value is accepted, else it should have
  314.     displayed a message using 'CRT_Error', and the user will have to
  315.     change the value. This routine had better work right, or the user
  316.     might not have any way to enter a value which IS accepted.
  317.  
  318.     CRT_FormIntOK(int n)bool
  319.  
  320.     This is a dummy int checker routine that just returns 'true'.
  321.  
  322.     CRT_FormChars(ushort line, column, length; *char heading;
  323.           *bool pChanged; *char buffer;
  324.           proc (*char value)bool checker)void
  325.  
  326.     This adds a string field to the current input form in a way totally
  327.     analagous to 'CRT_FormInt'. 'buffer' points at a buffer which
  328.     contains the initial value, and into which the final value is placed.
  329.  
  330.     CRT_FormRead(*char header; byte flags; *char terminators)char
  331.  
  332.     This routine presents and handles the input form specified by calls
  333.     to the previous routines. 'header' is a (possibly multiline) header
  334.     that is to be displayed at the top of the screen. As with CRT_Menu,
  335.     the header lines will be centered on the screen. 'flags' consists of
  336.     any combination of the following (defined in FORM.G):
  337.  
  338.         FORMHEADERS = 0x01 - specifies that the form and field headers
  339.         are to be displayed on this call. If the same form is used
  340.         several times in succession, much annoying screen I/O is
  341.         avoided if only the first use has FORMHEADERS set.
  342.         FORMSKIP = 0x02 - enables automatic skipping from one field to
  343.         the next at the end of a field and skipping from one field
  344.         to the previous when a backspace is typed at the beginning
  345.         of a field.
  346.         FORMINPUT = 0x04 - enables the input of data to the fields.
  347.         A call without this flag is useful for nicely displaying
  348.         the information.
  349.         FORMOUTPUT = 0x08 - enables all displaying associated with the
  350.         input form. Output is not needed if the program knows that
  351.         the current screen contents is correct. This could be from,
  352.         say, the user asking to edit the current record during a
  353.         browse of a set of records. (The browse would use CRT_GetChar
  354.         to input the browsing commands, one of which would request
  355.         the edit.)
  356.  
  357.     Parameter 'terminators' is a string containg the characters that
  358.     are to be recognized as field terminators. CRT_FormRead recognizes
  359.     the following as special:
  360.  
  361.         CONTROL-R - undo changes to the current field
  362.         CONTROL-Q - quick exit with fields as they appear
  363.         CONTROL-Z - cancel all changes and redraw the fields
  364.         ESCAPE - cancel all changes, redraw the fields, and exit
  365.  
  366.     These special functions are enabled by including the corresponding
  367.     characters in the 'terminators' string. 'FORM.G' declares a string
  368.     constant, 'TERMINATORS', containing just these terminators.
  369.     CRT_FormRead returns the terminator character which the user typed
  370.     to terminate form input. Note that CRT_FormRead uses CRT_ClearError
  371.     and the storage allocator (for structures and backup buffers).
  372.  
  373.     The screen is NOT cleared either before or after the the form is
  374.     displayed and read. The programmer is responsible for this. This is
  375.     done so that a form can appear in a small section of the screen. For
  376.     example, the screen might be divided into two parts, each of which
  377.     is used as an input form for different, but related data. Careful
  378.     use of the flags can result in a very clean use of screen updates.
  379.